home *** CD-ROM | disk | FTP | other *** search
/ Guide To Cracking 2002 / Guide_to_Cracking_2002.iso / Tutorials / Nag and Time Trial / nag / ns46.txt < prev    next >
Encoding:
Text File  |  2000-04-19  |  5.3 KB  |  137 lines

  1.                    Cracking MaxSpace - Removing a little nag
  2. --------------------------------------------------------------------------
  3.                       [x] Easy [ ] Intermediate [ ] Tough
  4.  
  5. Get MaxSpace at: Search the web :p
  6. Tools used:
  7.     * Soft-ICE
  8.     * HIEW
  9.  
  10. MaxSpace is a programme for Borland Delphi/C++ Builder that turns object
  11. inspector or IDE toolbar into "auto-hide" windows, so that you can write
  12. code on a full screen.
  13.  
  14. Since the protection is a nag, we know we are going to patch it, make a
  15. backup of the executable files (*.EXE, *.DLL, *.OCX) before trying to
  16. patch them.
  17.  
  18. The protection of the programme is a nag, and we see the nag is some kind
  19. of message box, because we see it's a regular window with an information
  20. icon that has a single OK button, it's too simple and we can identify this
  21. as a message box. So we put a breakpoint on the three most probable
  22. procedures used to draw this window:
  23.  
  24. :bpx MessageBoxA
  25. :bpx MessageBoxIndirectA
  26. :bpx MessageBoxExA
  27.  
  28. No we run MaxSpace.. Surprise surprise!  Soft-ICE breaks at the API
  29. function MessageBoxA.. Now we want to remove the CALL to this API
  30. function, so we press F11 - This will return to the programme's code
  31. (after you pressed the OK button) and then write down the position, which
  32. is 48A84B. Notice that we are not in MAXSPACE.EXE code, we are at
  33. MAXHOOK.DLL! Since we were executing the code, and not using a dead
  34. listing, we know that the address is not a regular address, it is a
  35. linear address, which is relocated upon loading of the programme. So we
  36. first must convert it to a virtual address, simply by subtracting the
  37. executable's image base which is in this case 400000, then we get a
  38. virtual offset: 8A84Bh.
  39. Take HIEW and edit MAXHOOK.DLL, we pass to disassemble mode (by using F4)
  40. and then we want to go to that address, so we use Goto option (F5) and
  41. type .8A84B (the dot is so HIEW will know that this is a virtual address)
  42. -- Error! "Section out file".. What do we do now?
  43.  
  44. Now we need to get few bytes from near the message box call address and
  45. search them in the real file.
  46. Put a breakpoint on MessageBoxA and run MaxSpace. Press F11 to return to
  47. programme's code, then type this:
  48.  
  49. :db cs:48A846                   <- this is the CALL offset
  50.  
  51. This will give you a list of bytes in the code position (cs - code segment)
  52. Write down the hexadecimal value of few bytes, I wrote down:
  53.  
  54. E8 E9 BF FD FF 89 45 F8 33 C0 5A 59 59 64
  55.  
  56. Now, exit MaxSpace and load MAXHOOK.DLL in HIEW. Switch to disassembly
  57. mode then press F7 to search the file. Now go to HEX entry and type the
  58. hex values. Found!
  59. Search for another occurence by using CTRL+F7.. Not found, this means that
  60. this string is the nag code.
  61.  
  62. Now, if you look at the API reference for MessageBox(A), you will see it
  63. receives 4 parameters:
  64.  
  65.     int MessageBox(
  66.         HWND  hWnd,         /* handle of owner window           */
  67.         LPCTSTR  lpText,    /* address of text in message box   */
  68.         LPCTSTR  lpCaption, /* address of title of message box  */
  69.         UINT  uType         /* style of message box             */
  70.     );
  71.  
  72. In assembly, every parameter/parameter offset have to be PUSHed before we
  73. call the function, so we scroll up till we see four PUSHes before the
  74. call, by the way, in assembly, the parameters are backwards, so it's like
  75. that:
  76.  
  77.     push ebx                            ; Message box style
  78.     push edi                            ; Message box title's address
  79.     push esi                            ; Message box text's address
  80.     mov eax, [ebp][-0004]
  81.     mov eax, [ebp][00024]
  82.     push eax                            ; Owner window's handle
  83.     call MessageBoxA                    ; Call function
  84.     mov [ebp][-0008], eax               ; Save return code
  85.  
  86. Now we want to remove the Message box, there's a command in assembly that
  87. tells the computer to 'skip' to next instruction, it's called NOP (no
  88. operation), we'll use it.
  89.  
  90. Since we don't want to give this parameters for nothing, we don't only NOP
  91. the call, we also NOP the parameter PUSHing.. Edit the file at the 'push
  92. ebx' offset, and type '90'. This will place 90h instead of the push (53h).
  93. You see that HIEW says 'nop'. NOP the other pushes as well..
  94.  
  95. Now we need to NOP the call, how do we do that? Simple, like the pushes,
  96. just that we NOP the whole call, not just one byte.. Count how much bytes
  97. the call is, it's 5 (every byte is two hexadecimal letters). So we need to
  98. press 90 five times. Do it. Now press F9 to update the file.
  99.  
  100. The code shold look like this now:
  101.  
  102.     nop
  103.     nop
  104.     nop
  105.     mov eax, [ebp][-0004]
  106.     mov eax, [ebp][00024]
  107.     nop
  108.     nop
  109.     nop
  110.     nop
  111.     nop
  112.     nop
  113.     mov [ebp][-0008], eax
  114.  
  115. Now the programme should run just fine, we think we eliminated the nag..
  116. Run MaxSpace.. NO NAG! It's magic :)
  117.  
  118. However, sometimes the nag has few buttons, in this case we have to emulate
  119. the return code.. The return code that should be for this nag is IDOK (the
  120. user should press OK :).. IDOK is defined as 1.. So we put some more code
  121. instead of the NOPs:
  122.  
  123.     nop
  124.     nop
  125.     nop
  126.     mov eax, [ebp][-0004]
  127.     mov eax, [ebp][00024]
  128.     mov eax, 1
  129.     nop
  130.     mov [ebp][-0008], eax
  131.  
  132. That's it! Now run the programme and enjoy!
  133.  
  134.  
  135.                                                 - DEATH
  136.                                               <ab4ds@hotmail.com>
  137.